Use Algolia Recommendations on your Salesforce B2C Commerce storefront.
recommend-js
library with Algolia’s SFRA cartridge, you can deliver product recommendations to enhance the shopping experience for your users.
To learn how recommendations work, see Algolia Recommend.
session.privacy.algoliaAnchorProducts
or specify them directly and statically in the content slot’s Product field. Depending on the widget and recommendation requirements, you can specify either single or multiple anchor products.
autocomplete-config.js
file.
algoliaAnchorProducts
in either the corresponding controller or the ISML template file. For example, you can do this in the Wishlist
controller or the wishlist.isml
template file if you want to show recommendations based on the products in the shopper’s wishlist.
Cart-Show
and Product-Show
controllers, as the Algolia SFRA cartridge already sets this variable.
Therefore, unless there are specific customizations in your instance or you want to change this default behavior, you can directly utilize content slots on these pages to display recommendations based on products in the cart on the basket page and the currently displayed product on the product detail page, respectively.categoryDisplayNamePath
variable.
This variable is automatically set in the Search.js
Controller file for categories and then used as the facetValue
in the widget.
To display popular items for a different facet, customize the logic.
For more details, refer to the trending items widget reference.session.privacy.algoliaAnchorProducts
. You can set this variable in your controller or ISML template file. The following example sets this variable and creates a new content slot:
session.privacy.algoliaAnchorProduct
, similarly to the Frequently Bought Together widget preceding. You can set this variable in your controller or ISML template file.
Here is an example of setting this variable and creating a new content slot:
Content Type
as Product
and choose the template as Related Products
.
For more details, refer to the related products widget API reference.
lsImage
attribute to be available in the index to provide the reference image to the model. You can send this attribute to Algolia by adding it to the Additional Product Attributes setting in the Algolia Business Manager module Custom Preferences.
lsImage
as the image attribute.session.privacy.algoliaAnchorProduct
. See the Frequently Bought Together widget.data-object-ids
attribute is used to pass the object ids of the current content to the widget.
int_algolia_sfra/cartridge/static/default/js/algolia/autocomplete-config.js
file, set useTrendingItems
to true
.
maxRecommendations
variable within the autocomplete-config.js
file to alter the number of trending items displayed. Additionally, you can tailor the styling, placement, and ordering of the trending items through modifications in this file.
recommend-js
library. For details, see the recommend-js
reference. You might also want to add optimizations such as scrolling or pagination to iterate through shown recommendations.
Algolia Recommend can deduplicate product variants with the distinct
setting. For example, if you use a variant-level record model and you want to avoid showing duplicate product tiles for different variants, such as different sizes or different colors, use the masterID
index attribute as your deduplication attribute (attributeForDistinct
).
int_algolia_sfra/cartridge/static/default/js/algolia/autocomplete-config.js
cartridges/int_algolia_sfra/cartridge/static/default/js/algolia/recommend-config.js
cartridges/int_algolia_sfra/cartridge/templates/default/slots/product